import {ExtractPropTypes, PropType} from "vue";

export const tableProps = {
    //表格字段数据
    columns: {
        type: Array as PropType<Column[]>,
        default: [],
        required: true
    },
    //表格参数
    tableAttr:{
        type: Object
    },
    cellHeight:{
        type: String,
        default: "32px"
    }
}

export type TableProps = ExtractPropTypes<typeof tableProps>;
export enum EditFlagEnum {
    ORIGINAL = 'original',
    ADD = 'add',
    UPDATE = 'update',
    REMOVE = 'remove'
}
export interface TableRow {
    $index: number,
    column: TableRowColumn

}
export interface TableRowColumn {
    property: string
}

export interface Column {
    label: string,
    type?: string,
    prop?: string,
    readonly?: boolean,
    align: 'center' | 'right' | 'left',
    fixed?: 'right' | 'left',
    headerAlign: 'center' | 'right' | 'left',
    width?: string | number,
    component?: 'Input' | 'Select' | 'Switch' | 'InputNumber' | 'SelectTree',
    componentAttr?: ComponentAttr,
    rules?: Rule[],
    custom?: string
}
export interface Rule {
    required?: Boolean,
    message: string,
    trigger: 'blur' | 'change',
    min?: number,
    max?: number
}
export interface ComponentAttr {
    data?: object,
    placeholder?: string,
    options?: any
    activeValue?: string | number,
    inactiveValue?: string | number,
    toNumber?: boolean,
    toStr?: boolean,
    props?: object,
    checkStrictly?: boolean

}